package com.github.littleantfly.dictionarydemo.service;

import com.github.littleantfly.dictionary.module.DictModel;
import com.github.littleantfly.dictionary.service.DictService;
import com.github.littleantfly.dictionarydemo.DefaultDictCache;
import org.springframework.stereotype.Service;

import java.util.Optional;


/**
 * 自定义字典数据获取示例，当此配置激活后，{@link com.github.littleantfly.dictionarydemo.CacheDataInitDemo} 将无效
 * @author xiezhenglong
 */
@Service
public class CustomDictServiceImplDemo implements DictService {

    @Override
    public Optional<DictModel> getDictData(String data, Object fieldValue) {
        return Optional.of(DefaultDictCache.get(String.format("%s:%s", data, fieldValue)));
    }

}
